#include "StdAfx.h"
#include "Square.h"
#include "IElement.h"
#include "LocalPane.h"

CIElement::CIElement(CLocalPane* pSquarePane, CPoint firstPoint, UINT nSquareWidth, ElementState state, SpinMode mode, COLORREF color) 
	: CElement(pSquarePane, firstPoint, nSquareWidth, IELEMENT_STATE_COUNT, color, state, mode)
{
	ASSERT(m_pSquarePane != NULL );

	ConstructSquareList(state, firstPoint, nSquareWidth, m_listSquare);
}

CIElement::~CIElement(void)
{
}

/////////////////////////////////////////////////////////////////////////////////////////

void CIElement::ConstructSquareList(ElementState state, CPoint pntFirstPoint, UINT nSquareWidth, SquareList& listSquare) const
{
	listSquare.clear();

	switch (state)
	{
	case ES_FIRST:
    case ES_THIRD:
		{
			for (int i = 0; i < 4; ++i)
			{
				listSquare.push_back(CSquare(m_pSquarePane, CPoint(pntFirstPoint.x, pntFirstPoint.y + i * nSquareWidth), nSquareWidth, true, m_ElementColor));
			}

			break;
		}
	case ES_SECOND:
    case ES_FOURTH:
		{
			for (int i = 0; i < 4; ++i)
			{
				listSquare.push_back(CSquare(m_pSquarePane, CPoint(pntFirstPoint.x + i * nSquareWidth, pntFirstPoint.y), nSquareWidth, true, m_ElementColor));
			}

			break;
		}
	default:
		break;
	}
}